Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
intl-format-cache
Advanced tools
Produces instances of JavaScript `Intl` formats, and caches them for reuse.
The intl-format-cache npm package is a utility for caching instances of Intl formatters, such as Intl.DateTimeFormat, Intl.NumberFormat, and Intl.RelativeTimeFormat. This can improve performance by reusing formatter instances instead of creating new ones each time formatting is needed.
Caching DateTimeFormat instances
This feature allows you to cache instances of Intl.DateTimeFormat. The code sample demonstrates how to create and reuse a DateTimeFormat instance for formatting dates in 'en-US' locale.
const { getDateTimeFormat } = require('intl-format-cache');
const dateTimeFormat = getDateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
console.log(dateTimeFormat.format(new Date()));
Caching NumberFormat instances
This feature allows you to cache instances of Intl.NumberFormat. The code sample demonstrates how to create and reuse a NumberFormat instance for formatting numbers as currency in 'en-US' locale.
const { getNumberFormat } = require('intl-format-cache');
const numberFormat = getNumberFormat('en-US', { style: 'currency', currency: 'USD' });
console.log(numberFormat.format(123456.789));
Caching RelativeTimeFormat instances
This feature allows you to cache instances of Intl.RelativeTimeFormat. The code sample demonstrates how to create and reuse a RelativeTimeFormat instance for formatting relative time in 'en-US' locale.
const { getRelativeTimeFormat } = require('intl-format-cache');
const relativeTimeFormat = getRelativeTimeFormat('en-US');
console.log(relativeTimeFormat.format(-1, 'day'));
The intl package provides a polyfill for the ECMAScript Internationalization API, which includes Intl.DateTimeFormat, Intl.NumberFormat, and Intl.RelativeTimeFormat. Unlike intl-format-cache, it focuses on providing the functionality where it is not natively available, rather than caching instances.
The formatjs package is a collection of libraries for internationalization in JavaScript, including react-intl and intl-messageformat. It provides more comprehensive solutions for formatting dates, numbers, and messages, but does not specifically focus on caching formatter instances like intl-format-cache.
The globalize package provides a comprehensive internationalization library based on the Unicode CLDR data. It supports formatting dates, numbers, and messages, and offers more extensive localization features compared to intl-format-cache, but does not specifically focus on caching formatter instances.
Produces instances of JavaScript Intl
formats, and caches them for reuse.
This is an helper package used within Yahoo's IntlJS suite. It provides a cache layer for creating Intl
format instances: IntlNumberFormat
, Intl.DateTimeFormat
, and IntlMessageFormat
.
This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.
FAQs
A memoizer factory for Intl format constructors.
The npm package intl-format-cache receives a total of 178,649 weekly downloads. As such, intl-format-cache popularity was classified as popular.
We found that intl-format-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.